import Vue from 'vue';
import App from '../App.vue';
import Router from 'vue-router';
import LoginPage from '../views/LoginPage.vue';
import LeftAside from '../views/LeftAside.vue';
import UserList from '../views/User.vue';
import ClassManagement from '../components/ClassManagement.vue';
import StudentManagement from '../components/StudentManagement.vue';
import HomeIndex from '../views/Home.vue';
import AddStudent from '../components/AddStudent.vue';
import UpdStudent from '../components/UpdStudent.vue';
import FieldManage from '../field/FieldManage.vue';
import Leave from '../components/stuLeave/Leave.vue';
import Approval from '../components/stuLeave/Approval.vue';
import AccessManage from '../accessControl/AccessManage.vue';
import Rule from '../accessControl/Rule.vue';
import AccessControlInfo from '../accessControl/AccessControlInfo.vue';
import Gateway from '../apartment/Gateway.vue';
import EwDeviceManger from '../apartment/EwDeviceManger.vue';
import ElectricityUse from '../apartment/ElectricityUse.vue';
import Role from '../views/Role.vue';

Vue.use(Router);

const router = new Router({
  routes: [
    { path: '/', redirect: '/login' },
    { path: '/login', component: LoginPage },
    {path: '/LeftAside', component: LoginPage},
    {path: '/index', component: LeftAside,
      children: [
        { 
          path: '/user', 
          components: {'user': UserList}
        },
        { 
          path: '/role', 
          components: {'role': Role}
        },
        {
          path: '/classManagement', 
          components: {'classManagement': ClassManagement}
        },
        {
          path: '/studentManagement', 
          components: {'studentManagement': StudentManagement}
        },
        {
          path: '/home', 
          components: {'home': HomeIndex}
        },
        {
          path: '/addStudent', 
          components: {'addStudent': AddStudent}
        },
        {
          path: '/updStudent', 
          name: 'updStudent',
          components: {'updStudent': UpdStudent}
        },
        {
          path: '/fieldManage', 
          components: {'fieldManage': FieldManage}
        },
        {
          path: '/leave', 
          components: {'leave': Leave}
        },
        {
          path:'/approval',
          components: {'approval': Approval}
        },
        {
          path:'/accessManage',
          components: {'accessManage': AccessManage}
        },
        {
          path:'/rule',
          components: {'rule': Rule}
        },
        {
          path:'/accessControlInfo',
          components: {'accessControlInfo': AccessControlInfo}
        },
        {
          path:'/gateway',
          components: {'gateway': Gateway}
        },
        {
          path:'/ewDeviceManger',
          components: {'ewDeviceManger': EwDeviceManger}
        },
        {
          path:'/electricityUse',
          components:{'electricityUse':ElectricityUse}
        }
      ]
    },
  ],
});

new Vue({
  el: '#app',
  render: h => h(App),
  router,
});

export default router;